package mya_dc.shared_classes;

import java.io.Serializable;


/**
 * A wrapper for messages
 *
 * 
 * @author      Adam Levi
 * @author		Yuval Shimron
 * @author 		Marina Skarbovski
 * <br>			MYA
 */
public class Message implements Serializable
{
	private static final long serialVersionUID = 1L;
	public Message(EMessageType type, Object obj)
	{
		m_MessageType = type;
		m_Obj = obj;
	}
	public enum EMessageType {
		SUCCESS,
		UNEXPECTED_MESSAGE,
		LOGIN,
		LOGIN_NEW,
		LOGIN_NEW_PROJECT_SIZE,
		LOGIN_EXISTING,
		LOGIN_COMPLETE,
		LOGIN_FAILED_AUTHENTICATION_FAILED,
		LOGIN_FAILED_USERNAME_ALREADY_EXISTS,
		LOGIN_FAILED_ID_ALREADY_IN_USE,
		LOGIN_FAILED_OUT_OF_SPACE,
		LOGIN_FAILED_NO_MORE_SERVERS,
		LOGIN_REQUESTING_NEW_SERVER,
		LOGIN_REGISTER_NEW_PROJECT,
		LOGIN_PROJECT_NAME,
		LOGIN_CONNECTION_TO_SERVER_SUCCEEDED,
		
		LOGIN_COMPILATION_SERVER_INFO,
		LOGIN_COMP_SERVER_LIST_OF_SERVERS,
		LOGIN_DELETE_MAPPING,
		
		LOGIN_FAILED_SERVER_DISCONNECTED,
		LOGIN_ENTITY_IDENTIFICATION,
		
		LOGIN_CONNECTION_TO_ALL_SERVERS_FAILED,
		
		FILE_TRANSFER_START,
		FILE_TRANSFER,
		FILE_TRANSFER_DONE,
		
		PROJECT_VERIFICATION_START,
		PROJECT_VERIFICATION_DONE,
		
		OPERATION_CANCELED,
		
		COMPILATION_RESULT_ERRORS,
		COMPILATION_RESULT_NO_ERRORS,
		COMPILATION_GET_SLAVES,
		COMPILATION_COMPILE_PROJECT,
		COMPILATION_SET_FLAGS,
		COMPILATION_NUM_OF_SLAVES,
		SERVER_SYNCHRONIZE_DATABASE,
		SERVER_SYNCHRONIZE_OK,
		SERVER_SYNCHRONIZE_DELETE_USERS,
		SERVER_SYNCHRONIZE_DELETE_USERPROJECT,
		
		COMPILATION_SLAVE_DONE,
		COMPILATION_DONE,
		COMPILATION_UNABLE_TO_COMPILE,
		COMPILATION_NO_SLAVES,
		
		FILE_TRANSFER_OBJECT_FILES,
		FILE_TRANSFER_NO_OBJECT_FILES,
		FILE_TRANSFER_NO_MORE_FILES,
		INET_ADDRESS,
		LISTEN_PORT,
		
		TRANSMITTER_PACK_OF_FILES_START,
		TRANSMITTER_PACK_OF_FILES_FILE_TRANSFER,
		TRANSMITTER_PACK_OF_FILES_DONE,
		
		SLAVEISDONE,
		TRANSMITTER_KEEPALIVE_MSG,
		
		//inner messages
		ERROR_MASTER_SERVER_CONNECTION_FAILED,
	};
	
	/**
	 * gets the message's type
	 */
	public EMessageType getType()
	{
		return m_MessageType;
	}
	
	/**
	 * gets the message's object
	 */
	public Object getObject()
	{
		return m_Obj;
	}
	
	/**
	 * sets the message's object
	 */
	public void setObject(Object obj)
	{
		m_Obj = obj;
	}
	
	/**
	 * sets the message's type
	 */
	public void setType(EMessageType type)
	{
		m_MessageType = type;
	}
	private EMessageType m_MessageType;
	private Object m_Obj;
}
